package com.java.demo;

import com.java.crazy.base.BaseClass;
import com.java.demo.bean.People;

import java.io.File;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class demo extends BaseClass {
    public static void main(String[] args) {
//        calcute();
//        People people = new People();
//        people.setName("lb");
//        final int a = 2;
//        int b = 3;
//        print(people, a, b);
//        logi("3: " + a + "----" + b + "------" + people.getName() + "----" + people.hashCode());
//        getFileTime();
//        logi(jsonstrAllLoadbear);
//replaceDomain("www.baidu.com",null,"https://www.douyu.com/topic/cxxjh_A?rid=252140");
//        replace();
//        calcute();
        replace2();
//        splite();
    }

    private static void splite() {
        String STR = "/storage/emulated/0/Pictures/Screenshots/SVID_20190702_111052_1.mp4";
        String[] strings=STR.split("/");
    }

    private static void replace2() {
        String phone = "+86 157 5538 7004";
        logi(phone.replace("+86", "").replace(" ", ""));
    }

    private static void replace() {
        String[] IMG = new
                String[]{"<img size=790x398>//img.alicdn.com/imgextra/i1/1670953622/O1CN01rtBTfK1ccv2lJXKP7_!!1670953622.jpg</img>",
                "<img size=790x636>//img.alicdn.com/imgextra/i2/1670953622/O1CN01lTLkXP1ccv4U3TUUX_!!1670953622.jpg</img>",
                "<img size=790x1357>//img.alicdn.com/imgextra/i3/1670953622/TB2q9iOsHlmpuFjSZFlXXbdQXXa_!!1670953622.jpg</img>",
                "<img size=790x790>//img.alicdn.com/imgextra/i4/1670953622/TB2D5eNirJkpuFjy1zcXXa5FFXa_!!1670953622.jpg</img>",
                "<img size=790x597>//img.alicdn.com/imgextra/i3/1670953622/TB2_Ju5d4RDOuFjSZFzXXcIipXa_!!1670953622.jpg</img>",
                "<img size=790x1246>//img.alicdn.com/imgextra/i1/1670953622/TB2NJc2XVrB11BjSspjXXciYpXa_!!1670953622.jpg</img>",
                "<img size=790x520>//img.alicdn.com/imgextra/i2/1670953622/TB2pj.1X2PB11BjSsppXXcjYVXa_!!1670953622.jpg</img>",
                "<img size=790x946>//img.alicdn.com/imgextra/i4/1670953622/TB2gpsZXWLB11BjSspkXXcy9pXa_!!1670953622.jpg</img>",
                "<img size=790x765>//img.alicdn.com/imgextra/i3/1670953622/TB2TQw4X3_z11Bjy1XbXXaScFXa_!!1670953622.jpg</img>",
                "<img size=790x698>//img.alicdn.com/imgextra/i4/1670953622/TB2FtoLbBLzQeBjSZFDXXc5MXXa_!!1670953622.jpg</img>",
                "<img size=790x631>//img.alicdn.com/imgextra/i1/1670953622/TB25Uw0X._C11Bjy1zeXXXtGpXa_!!1670953622.jpg</img>",
                "<img size=790x582>//img.alicdn.com/imgextra/i1/1670953622/TB2c23taXPcZ1BjSZFlXXb3PVXa_!!1670953622.jpg</img>",
                "<img size=790x967>//img.alicdn.com/imgextra/i4/1670953622/TB2OHk0XZrC11Bjy1zjXXcduVXa_!!1670953622.jpg</img>",
                "<img size=790x1227>//img.alicdn.com/imgextra/i1/1670953622/O1CN011ccv0WFZSQ5tItK_!!1670953622.jpg</img>"};
        logi("");
        for (String string : IMG) {
            String img = string.replace("http:", "").replace("https:", "");
            img = img.split(">//")[1];
            img = img.split("</img>")[0];
            logi("http://" + img);
            img = "<img width=\"100%\" src=\"http://" + img + "\"/>";
            logi(img);
        }

    }

    public static String replaceDomain(String domain, String port, String url) {
        String url_bak = "";
        if (url.indexOf("//") != -1) {
            String[] splitTemp = url.split("//");
            url_bak = splitTemp[0] + "//";
            if (port != null) {
                url_bak = domain + ":" + port;
            } else {
                url_bak = domain;
            }

            if (splitTemp.length >= 1 && splitTemp[1].indexOf("/") != -1) {
                String[] urlTemp2 = splitTemp[1].split("/");
                if (urlTemp2.length > 1) {
                    for (int i = 1; i < urlTemp2.length; i++) {
                        url_bak = url_bak + "/" + urlTemp2[i];
                    }
                }
                System.out.println("url_bak:" + url_bak);
            } else {
                System.out.println("url_bak:" + url_bak);
            }
        }
        return url_bak;
    }

    private static void getFileTime() {
        File file = new File("C:\\Users\\sixbing\\Desktop\\临时文件\\1540742400000");
        if (file.getName() == null) {
            return;
        }
        long time = file.lastModified();//返回文件最后修改时间，是以个long型毫秒数
        String stime = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss").format(new Date(time));
        String ctime = new SimpleDateFormat("yyyy-MM-dd HH:MM:ss").format(new Date());
        System.out.println(stime + "---" + ctime);
        try {
            int day = daysBetween(stime, ctime);
            System.out.println(day);
            file.delete();
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    /**
     * 计算两个日期之间相差的天数
     * 字符串的日期格式的计算
     */
    public static int daysBetween(String smdate, String bdate) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar cal = Calendar.getInstance();
        cal.setTime(sdf.parse(smdate));
        long time1 = cal.getTimeInMillis();
        cal.setTime(sdf.parse(bdate));
        long time2 = cal.getTimeInMillis();
        long between_days = (time2 - time1) / (1000 * 3600 * 24);
        int days = Integer.parseInt(String.valueOf(between_days));
        cal.clear();
        cal = null;
        return days;
    }

    private static void print(People people, int a, int b) {
        logi("1: " + a + "----" + b + "------" + people.getName() + "----" + people.hashCode());
        a = 22;
        b = 33;
        people.setName("lblb");
        logi("2: " + a + "----" + b + "------" + people.getName() + "----" + people.hashCode());
    }

    private static void percent() {
        double percent = 2 * 100 / (float) 30000;
        BigDecimal b = new BigDecimal(percent);
        float f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
        logi(percent + "----" + f1);
    }

    private static void calcute() {
        logi("--->计算进位 1/0.333,12*0.333");
        float aaa = 0.333f;

        logi((int) Math.ceil(12 * aaa));

        logi("\n");
//        int mReachHeight = 10;
//        float sweepAngle = 90;
//        for (int i = 0; i < sweepAngle; i++) {
//            float height = (float) (mReachHeight * (1 + 2 * (i) / sweepAngle));
//            logi(i + "--->" + height);
//        }

    }

    public static String jsonstrAllLoadbear = "[{\n" +
            "    \"name\": \"柯岩风景区\",\n" +
            "    \"id\": \"1\",\n" +
            "    \"current\":\"4019\",\n" +
            "    \"count\":\"30631\",\n" +
            "    \"phone\":\"84365566\",\n" +
            "    \"linkman\":\"包秀萍\"\n" +
            "  }, {\n" +
            "    \"name\": \"大香林风景区\",\n" +
            "    \"id\": \"2\",\n" + "    " +
            "    \"current\":\"7209\",\n" +
            "    \"count\":\"46763\",\n" +
            "    \"phone\":\"84380728\",\n" +
            "    \"linkman\":\"鲁国庆\"\n" +
            "  }, {\n" +
            "    \"name\": \"安昌古镇\",\n" +
            "    \"id\": \"3\",\n" +
            "    \"current\":\"8000\",\n" +
            "    \"count\":\"34000\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"中国轻纺城市场景区\",\n" +
            "    \"id\": \"4\",\n" +
            "    \"current\":\"8000\",\n" +
            "    \"count\":\"20000\",\n" +
            "    \"phone\":\"85528002\",\n" +
            "    \"linkman\":\"竹丽君\"\n" +
            "  }, {\n" +
            "    \"name\": \"中国轻纺城\",\n" +
            "    \"id\": \"5\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"东方山水乐园\",\n" +
            "    \"id\": \"6\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"22000\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"浙江国际赛车场\",\n" +
            "    \"id\": \"7\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"瓜渚湖\",\n" +
            "    \"id\": \"8\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"坂湖公园\",\n" +
            "    \"id\": \"9\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"舜王庙\",\n" +
            "    \"id\": \"10\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"600\",\n" +
            "    \"phone\":\"85282955\",\n" +
            "    \"linkman\":\"周红燕\"\n" +
            "  }, {\n" +
            "    \"name\": \"香雪梅海\",\n" +
            "    \"id\": \"11\",\n" +
            "    \"current\":\"4850\",\n" +
            "    \"count\":\"11900\",\n" +
            "    \"phone\":\"85788218\",\n" +
            "    \"linkman\":\"蔡家苗\"\n" +
            "  }, {\n" +
            "    \"name\": \"千年香榧林景区\",\n" +
            "    \"id\": \"12\",\n" +
            "    \"current\":\"4500\",\n" +
            "    \"count\":\"8000\",\n" +
            "    \"phone\":\"85778250\",\n" +
            "    \"linkman\":\"黄天明\"\n" +
            "  }, {\n" +
            "    \"name\": \"越王峥\",\n" +
            "    \"id\": \"14\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"红豆仙霞景区\",\n" +
            "    \"id\": \"15\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"85770397\",\n" +
            "    \"linkman\":\"沈春焕\"\n" +
            "  }, {\n" +
            "    \"name\": \"王化·日铸岭\",\n" +
            "    \"id\": \"17\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"85731188\",\n" +
            "    \"linkman\":\"宋伟元\"\n" +
            "  }, {\n" +
            "    \"name\": \"绿林竹海\",\n" +
            "    \"id\": \"13\",\n" +
            "    \"current\":\"4000\",\n" +
            "    \"count\":\"7000\",\n" +
            "    \"phone\":\"85767686\",\n" +
            "    \"linkman\":\"徐岳尧\"\n" +
            "  }, {\n" +
            "    \"name\": \"柯桥古镇\",\n" +
            "    \"id\": \"16\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }, {\n" +
            "    \"name\": \"丹家村\",\n" +
            "    \"id\": \"18\",\n" +
            "    \"current\":\"\",\n" +
            "    \"count\":\"\",\n" +
            "    \"phone\":\"\",\n" +
            "    \"linkman\":\"\"\n" +
            "  }]";
}
